<?php
namespace app\common\behavior;

use think\Controller;
use think\Db;
use app\common\model\Configuration;
/*
 * 项目行为
 */
class App {
	protected $options = array();
	protected $config = '';
	public function __construct(){
	    $this->config = new Configuration();
    }
	public function run(&$params) {
	        if(config('app_debug')){
                cache('defaultinfo',false);
                cache('pagesize',false);
                cache('smtp',false);
                cache('sms',false);
            }

            $value =  $this->config->getkeyjson('defaultinfo');
            config('webtitle',$value->webtitle);
            config('defaultinfo', $value);

            if (!cache('pagesize')) {
                $value =  $this->config->getkey('pagesize');
                if(!$value){
                    cache('pagesize',10,0);
                }else{
                    cache('pagesize',$value,0);
                }
            }
            config('pagesize', cache('pagesize'));


            if (!cache('smtp')) {
                $value =  $this->config->getkeyjson('smtp');
                cache('smtp',$value,0);
            }
            config('smtp', cache('smtp'));


            if (!cache('sms')) {
                $value =  $this->config->getkeyjson('sms');
                cache('sms',$value,0);
            }
            config('sms', cache('sms'));
	}
}